﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShipConfig : MonoBehaviour
{
    public Control m_Controle;
    public WeaponGroupPanel m_GroupPanel;
    public Ship m_Ship;
    public GameObject m_BornPoint;
    public GameObject m_AndroidPanel;

    private void Awake()
    {
        Player.Instance.onSwitchCurrentShip.AddListener(onCurrentShipSwitched);
    }

    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    private void OnDestroy()
    {

        Player.Instance.onSwitchCurrentShip.RemoveListener(onCurrentShipSwitched);
    }

    void onCurrentShipSwitched(Ship currentShip)
    {
        m_Ship = Player.Instance.placeSelectShip(m_BornPoint.transform.position, currentShip.transform.rotation);
        m_Controle.ControlShp = m_Ship;
    }
    public void onGroupClicked()
    {
        if (null == m_GroupPanel)
            return;
        if (m_GroupPanel.gameObject.activeSelf)
            m_GroupPanel.Hide();
        else
            m_GroupPanel.Show(m_Ship);
    }

    public void onSaveClicked()
    {
    }

    public void OnTestClicked()
    {
#if UNITY_ANDROID
        if (m_AndroidPanel)
            m_AndroidPanel.SetActive(true);
#endif
    }
    public void OnEditClicked()
    {
#if UNITY_ANDROID
        if (m_AndroidPanel)
            m_AndroidPanel.SetActive(false);
#endif
    }
}
